<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>侦听器</title>
</head>

<body>
    <pre>
        侦听器： 监听并相应数据
    </pre>
    <div class="app">
        <div>
            <span>名:</span>
            <span>
                <input type="text" v-model="firstname">
            </span>
        </div>
        <div>
            <span>姓:</span>
            <span>
                <input type="text" v-model="lastname">
            </span>
        </div>
        <div>{{fullname}}</div>
    </div>
    <script src="./js/vue.js"></script>
    <script>
        var xm = new Vue({
            el: '.app',
            data: {
                firstname: '青',
                lastname: '刘',
                fullname: '刘青'
            },
            methods: {
            },
            watch: {
                firstname: function (val) {
                    this.fullname = this.lastname + val
                },
                lastname: function (val) {
                    this.fullname = val + this.firstname
                }
            }

        })

    </script>
</body>

</html>